<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Dashboard extends CI_Controller {

	public function admin(){
		$this->load->view('layout/head');
		$this->load->view('layout/header');
		$post = $this->input->post('submit');
		
		if($post){
			$this->load->model('modeladmin');
			$this->modeladmin->set_user($this->input->post('usr'));
			$this->modeladmin->set_password($this->input->post('pwd'));
			$this->form_validation->set_rules('usr', 'Nama Pengguna tidak boleh kosong', 'required');
			$this->form_validation->set_rules('pwd', 'Kata Sandi tidak boleh kosong', 'required');

			if ($this->form_validation->run() == FALSE){
				$data['error'] = validation_errors();
			}
			else{
				if($this->modeladmin->do_login()) {header('location: '.site_url().'/admin/dashboard');}
				else {$data['error'] = 'User dan Password yang anda masukkan tidak sesuai, silahkan periksa kembali';}
			}	
		}
		else
		{ 
			$data['error']   = $this->session->flashdata('error');			
		}

		$this->load->view('admin/admin-login' , $data);
		$this->load->view('layout/footer');
	}

	public function index(){
		$this->data['sidebar']  = 'sidebar';
		$this->data['konten'] = 'kontenisi';
		$this->data['konten1'] = 'home';
		$this->load->view('Dashboard', $this->data);
	}

	public function member(){
		$this->load->view('layout/head');
		$this->load->view('layout/header');
		$this->load->view('user/user-login');
		$this->load->view('layout/footer');
	}

	public function register(){
		$this->load->view('layout/head');
		$this->load->view('layout/header');
		$this->load->view('user/user-registe');
		$this->load->view('layout/footer');
	}	
	
	public function char(){
		$this->load->view('layout/head');
		$this->load->view('layout/headerchar');
		$this->load->view('char/keranjang');
		$this->load->view('layout/footer');
	}	
}		